#!/usr/bin/python
import psycopg2
print " import success "
conn = psycopg2.connect(database='logistics',host='localhost',user='postgres',password='postgres')
c=conn.cursor()
c.execute("select column_name,data_type from information_schema.columns where table_name = \'task\'order by ordinal_position")
records = c.fetchall()
column_format = ''
values_format = ''
for item in records:
    if column_format == '':
        column_format = "\'" + item[0] + "\'"
    else:
        column_format = column_format + "," + "\'" + item[0] + "\'"
        
        
    if values_format == '':
       if(item[1] == "timestamp without time zone"):
           values_format = "to_timestamp(\'%s\',\'YYYY-MM-DD HH24:MI:SS\')"
       else:     
           values_format ="\'" + "%s" + "\'"     
    else:
        if(item[1] == "timestamp without time zone"):
           values_format =  values_format + "," + "to_timestamp(\'%s\',\'YYYY-MM-DD HH24:MI:SS\')"
        else:     
           values_format = values_format + "," + "\'" + "%s" + "\'"
        
print column_format
print values_format    
import pprint
pprint.pprint(records) 